import numpy as np
import h5py
import os

if __name__ == '__main__':
    
    hdf_file = './gen_data/test.hdf5'
    # if not os.path.exists(hdf_file):
    #     open(hdf_file, 'a').close()

    # initializing a random numpy array
    arr = np.random.randn(1000)
    arr1 = np.random.randn(10000)
    arr2 = np.random.randn(10000)
 
    # creating a file
    with h5py.File(hdf_file, 'a') as f:
        if not f.get('default'):
            f.create_dataset("default", data = arr)
        if not f.get('array_1'):
            f.create_dataset('array_1', data = arr1)
        if not f.get('array_2'):
            f.create_dataset('array_2', data = arr2)

    # open the file as 'f'
    with h5py.File(hdf_file, 'r') as f:
        data = f['default']
        # get the minimum value
        print(min(data))
        
        # get the maximum value
        print(max(data))
        
        # get the values ranging from index 0 to 15
        print(data[:15])